# coding=utf-8
__author__ = '汤小洋'

'''
在打开文件并操作完成后，必须要关闭文件
'''
f = open('wbs.txt')
print(f.read())
f.close()  # 关闭文件

'''
使用with...as语句，会自动调用close()
'''
with open('wbs.txt') as f:
    print(f.read())

'''
异常处理
'''
try:
    with open('abc.txt') as f:
        print(f.read())
except FileNotFoundError as e:
    print('文件找不到：', e)
